<?php

/**
 * LoginBackend form.
 *
 * @package    form
 * @subpackage User
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */

class LoginForm extends sfFormExt
{
  protected function initialize()
  {
    $this->labels = array
                    (
                      'login'       => 'Usuario',
                      'password'    => 'Contraseña',
                    );
    $this->setOption('required_labels', false);
  }
  
  public function configure()
  {
    $this->setWidgets(array
    (
      'login'      => new sfWidgetFormInput(array(), array('size' => '20')),
      'password'   => new sfWidgetFormInputPassword(array(), array('size' => '20')),
    ));
    
    $this->setValidators(array
    (
      'login'      => new sfValidatorString(array('max_length' => 100)),
      'password'   => new sfValidatorString(array('max_length' => 255)),
    ));
    
    $this->types = array
    (
      'login'    => 'user',
      'password' => 'password',
    );
    
    $this->validatorSchema->setPostValidator
    (
      new LoginValidator
      (
        array
        (
          'model'       => 'Usuario', 
          'column'      => array('login', 'password'),
          'find_method' => 'findOneByLogin',
        )
      )
    );
  }
}
